home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / Apache 1.0 / src / Configure < prev    next >
Text File  |  1995-12-04  |  2KB  |  80 lines

  1. #! /bin/sh
  2.  
  3. # Apache configuration script, first cut --- rst.
  4. # Dont like it?  Inspired to do something better?  Go for it.
  5.  
  6. file=Configuration
  7. tmpfile=/tmp/htconf.$$
  8.  
  9. if [ "x$1" = "x-file" ] ; then
  10.   echo "Using alternate config file $2"
  11.   file=$2 
  12. else
  13.   echo "Using 'Configuration' as config file"
  14. fi
  15.  
  16. # First, strip comments and blank lines...
  17.  
  18. sed 's/#.*//' $file | sed '/^[     ]*$/d' | sed 's/[     ]*$//' > $tmpfile
  19.  
  20. # Check for syntax errors...
  21.  
  22. if grep -v = $tmpfile | \
  23.    egrep -v '^Module[     ]+[A-Za-z0-9_]+[     ]+[^     ]+$' > /dev/null
  24. then
  25.    echo "Syntax error --- each config file command must either"
  26.    echo "set a Makefile option, or configure a module (giving a"
  27.    echo "module name and a filename).  This doesn't appear to be"
  28.    echo "doing either:"
  29.    grep -v = $tmpfile | \
  30.       egrep -v '^Module[     ]+[A-Za-z0-9_]+[     ]+[^     ]+$'
  31.    rm $tmpfile
  32.    exit 1
  33. fi
  34.  
  35. # File is OK --- make backup copies of things and then get the new ones:
  36.  
  37. if [ -f Makefile ] ; then mv Makefile Makefile.bak; fi
  38. if [ -f modules.c ] ; then mv modules.c modules.c.bak; fi
  39.  
  40. awk >modules.c <$tmpfile '\
  41.    BEGIN { modules[n++] = "core_module" } \
  42.    /^Module/ { modules[n++] = $2 } \
  43.    END { print "/* modules.c --- automatically generated by Apache"; \
  44.          print " * configuration script.  DO NOT HAND EDIT!!!!!"; \
  45.          print " */"; \
  46.          print ""; \
  47.      print "#include \"httpd.h\""; \
  48.      print "#include \"http_config.h\""; \
  49.          print ""; \
  50.          for (i = 0; i < n; ++i) { \
  51.              printf ("extern module %s;\n", modules[i]); \
  52.          } \
  53.          print ""; \
  54.          print "module *prelinked_modules[] = {"; \
  55.          for (i = 0; i < n; ++i) { \
  56.              printf "  &%s,\n", modules[i]; \
  57.          } \
  58.      print "  NULL"; \
  59.          print "};"; \
  60.    }'
  61.  
  62. awk >Makefile <$tmpfile '\
  63.    BEGIN { print "# Makefile automatically generated from Makefile.tmpl"; \
  64.        print "# and configuration file by Apache config script. "; \
  65.        print "# Hand-edited changes will be lost if the config script"; \
  66.        print "# is re-run."; \
  67.          } \
  68.    /^Module/ { modules[n++] = $3 } \
  69.    /\=/ { print } \
  70.    END { print "MODULES=\\"; \
  71.          for (i = 0; i < n; ++i) { \
  72.              if (i < n-1) printf ("  %s \\\n", modules[i]); \
  73.              else printf ("  %s\n", modules[i]); \
  74.          } \
  75.          print "" \
  76.        }'
  77.  
  78. cat Makefile.tmpl >> Makefile
  79. rm $tmpfile
  80.